package com.yaiys.thread;

import java.util.concurrent.locks.LockSupport;

public class LockSuportTest {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            Thread current = Thread.currentThread();
            for (; ; ) {
                System.out.println("开始挂起");
                LockSupport.park();//线程中断，停一下车
                if (current.isInterrupted()){
                    System.out.println("我被中断了");
                }
                System.out.println("结束线程 ");

            }
        });
        thread.start();
        Thread.sleep(2000);
        LockSupport.unpark(thread);//线程中断结束，
        Thread.currentThread().interrupt();//阻断线程
        System.out.println("还清啦");
    }


}
